import { useRoutes, Navigate } from "react-router-dom";
import Home from '../pages/Home'
import About from '../pages/About'
import News from '../pages/News'
import Message from '../pages/Message'
import Details from '../pages/Details'
import React from "react";


export default function useRenderRoutes() {
    return (
        useRoutes([
            {
                // 首页
                path: '/home',
                element: <Home></Home>,
                children: [
                    {
                        index: true,
                        element: <Navigate to={'message'}></Navigate>
                    }, {
                        path: 'news',
                        element: <News></News>
                    }, {
                        path: 'message',
                        element: <Message></Message>,
                        children: [
                            {
                                path: ':id',
                                element: <Details></Details>
                            }
                        ]
                    }
                ]
            },
            {
                path: '/about',
                element: <About></About>
            }, {
                path: '/',
                element: <Navigate to={'/home'}></Navigate>
            }
        ])
    )
}
